<template>
  <div>
    <div class="left-box">
      <div class="box-main box1">
        <div class="title">实时统计</div>
        <div class="box">
          <echart :options="option1" />
        </div>
        <p>各年度产业变化</p>
        <div class="box">
          <echart :options="option2" />
        </div>
      </div>
      <!-- 左侧下 -->
      <div class="box-main box2">
        <div class="title">产业行业类别</div>
        <div class="box">
          <echart :options="option3" />
        </div>
      </div>
    </div>
    <div class="right-box">
      <div class="box-main box3">
        <div class="title">产业检索</div>
        <div class="cytj">
          <div class="cytjLi" v-for="item in cytjLi">
            <p><span class="font30">{{item.value}}</span>户</p>
            <p>{{item.name}}</p>
          </div>
        </div>
      </div>
      <div class="box-main box4">
        <div class="title">种植业规模统计</div>
        <div class="box">
          <echart :options="option4" />
        </div>
      </div>
      <div class="box-main box4">
        <div class="title">收入统计</div>
        <div class="box">
          <echart :options="option5" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Echart from "components/common/echart/Echart.vue";
import { echart10, echart11, echart12, echart13, echart14 } from "./option";
import { industryMonitoring } from "network/VRqj";
export default {
  components: { Echart },
  data() {
    return {
      option1: null,
      option2: null,
      option3: null,
      option4: null,
      option5: null,
      cytjLi: []
    };
  },
  mounted() {
    this.option4 = echart13()
  },
  created() {
    this.industryMonitoring(sessionStorage.getItem("cunId"));
  },
  methods: {
    async industryMonitoring(id) {
      let result = await industryMonitoring(id);
      let years1 = [],
        value1 = [];
      result.result.zongEconomy.forEach((element) => {
        years1.push(element.year);
        value1.push(element.economy);
      });
      this.option2 = echart11(years1, value1);
      let years2 = [],
        breed = [],
        crop = [];
      result.result.cropBreedYear.forEach((element) => {
        years2.push(element.year);
        breed.push(element.breed);
        crop.push(element.crop);
      });
      this.option5 = echart14(years2, [
        {
          name: "种植业",
          type: "line",
          data: crop,
        },
        {
          name: "养殖业",
          type: "line",
          data: breed,
        },
      ]);
    this.option3 = echart12(result.result.industrySector);
    this.option1 = echart10(result.result.piechartVos);
    this.cytjLi = result.result.cropBreedNum.map(el => {
      return {
        name: el.name,
        value: el.value
      }
    })
    },
    refurbish(id) {
      this.industryMonitoring(id)
    }
  }
};
</script>

<style lang="scss" scoped>
.left-box {
  .box1 {
    p {
      color: #fff;
      padding: 0 1.25rem;
    }
    .box {
      width: 100%;
      height: 10.625rem;
    }
  }
  .box2 {
    .box {
      width: 100%;
      height: 10.625rem;
    }
  }
}
.right-box {
  .box3 {
    .cytj {
      display: flex;
      justify-content: center;
      padding: 1.25rem;
      font-size: 0.875rem;
      .cytjLi {
        background: url(~assets/img/sy/cybg.png) no-repeat;
        background-size: 100% 100%;
        color: #00d8ff;
        margin: 0 0.625rem;
        width: 6.25rem;
        text-align: center;
        padding: 0.625rem 0;
        p {
          margin: 0rem 0;
          .font30 {
            font-size: 1.875rem;
            font-family: shuzi;
          }
        }
        p:nth-child(2) {
          color: #fff;
        }
      }
    }
  }
  .box4 {
    .box {
      width: 100%;
      height: 15.625rem;
    }
  }
}
</style>